<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j"
    template="layout/templateList.xhtml">

<ui:define name="body">

	<h2 class="title"><a href="#">Gerenciar Serviços</a></h2><br/>
	
    <h:form id="servicoForm">

	        <rich:dataTable value="#{manterServicoController.listaServicos}" var="_serv"
	        	id="tabelaServicos" rows="10">
	        	<rich:column>
	        		<f:facet name="header">
	        			<h:selectBooleanCheckbox value="#{manterServicoController.selecionadoTodos}">
	        				<a:support event="onchange" action="#{manterServicoController.selecionaTodos()}" reRender="tabelaServicos"/>
	        			</h:selectBooleanCheckbox>
					</f:facet>
	        		<h:selectBooleanCheckbox value="#{_serv.selecionado}" />
	        	</rich:column>
	        	
	        	<rich:column filterBy="#{_serv.dscNome}" filterEvent="onkeyup">
	        		<f:facet name="header">NOME</f:facet>
	        		<s:decorate template="/layout/editTable.xhtml">
		        		<h:outputText value="#{_serv.dscNome}"/>
					</s:decorate>
					<a:queue ignoreDupResponses="true"/>
	        	</rich:column>
	        	
	        	<rich:column>
	        		<f:facet name="header">VALOR</f:facet>
	        		<s:decorate template="/layout/editTable.xhtml">
		        		<h:outputText value="#{_serv.vlrServico}"
							converter="conversorMonetario"/>
					</s:decorate>
	        	</rich:column>
	        	
	        	<rich:column rendered="#{identity.hasRole('GERENCIAR_SERVICOS_GRAVAR')}">
	        		<f:facet name="header">EDITAR</f:facet>
	        		<s:decorate template="/layout/editTable.xhtml">
	        			<h:commandLink action="#{manterServicoController.editar(_serv)}" value="EDITAR" />
					</s:decorate>
	        	</rich:column>
	        	
	        </rich:dataTable>
	        <rich:datascroller for="tabelaServicos"/>
	        
	        <div class="actionButtons">
	        	<h:commandButton id="new" value="Novo" action="#{manterServicoController.novo}"
	        		rendered="#{identity.hasRole('GERENCIAR_SERVICOS_GRAVAR')}"
	        		reRender="tabelaServicos"/>
	            <h:commandButton id="remove" value="Excluir" action="#{manterServicoController.excluir()}"
	            	rendered="#{identity.hasRole('GERENCIAR_SERVICOS_EXCLUIR')}"
	            	onclick="javascript:if(!confirm('Tem certeza que deseja excluir o(s) serviço(s) selecionado(s)?'))return false;"/>
	        </div>

    </h:form>

 </ui:define>
</ui:composition>
